var lineChartData = {
    xAxis:["2014","2015","2016","2017","2018"],
    series:[
        {
            legend:'猕猴桃',
            color:'#3393ff',
            data:[10, 12, 15, 18, 26]
        },
        {
            legend:'柑橘',
            color:'#e8a443',
            data:[6, 10, 21, 22, 39]
        },
        {
            legend:'茶叶',
            color:'#42f3bf',
            data:[14, 17, 24, 30, 33]
        }
    ]
};


function init_lineChart(data) {
    function lineChart() {
        function lineitemStyle(obj) {
            return {
                normal: {
                    label: {
                        fontSize: 12,
                        padding: [50, 0, 0, 0],
                        color: '#fff',
                        textStyle: {
                            baseline: 'top'
                        }
                    },
                    color: obj && obj.borderColor || '#01f2ee',
                    borderColor: obj && obj.borderColor ||　'rgba(1, 242, 238, 0.5)',
                    borderWidth: 4
                }
            };
        }
        var legend = [];
        var series = [];
        data.series.forEach(function(e) {
            legend.push(e.legend);
            series.push({
                name: e.legend,
                smooth: true,
                type: 'line',
                symbolSize: 4,
                symbol: 'circle',
                itemStyle: lineitemStyle({borderColor:e.color}),
                data: e.data
            })
        });
        var lineoption = {
            legend: {
                data:legend,
                icon: 'circle',//图例形状
                right: -8,
                top:0,
                itemWidth: 8, // 图例标记的图形宽度。[ default: 25 ]
                itemHeight: 8, // 图例标记的图形高度。[ default: 14 ]
                itemGap: 10, // 图例每项之间的间隔。[ default: 10 ]横向布局时为水平间隔，纵向布局时为纵向间隔。
                textStyle: {
                    fontSize: 10,
                    color: '#ade3ff'
                },  
            },
            grid: {
                left: '0%',
                right: '0%',
                top: '20%',
                bottom: '0%',
                containLabel: true
            },
            tooltip: {
                show: true,
                trigger: 'item'
            },
            xAxis: {
                type: 'category',
                boundaryGap: true,
                axisTick: {
                    show: false
                },
                axisLine: {
                    show:false,
                    lineStyle: {
                        color: '#6995aa'
                    },
                    onZero: true
                },
                axisLabel: {
                    fontSize: 10,
                    color: '#6474b4'
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        type: 'dotted',
                        color: '#28379c'
                    }
                },
                data: data.xAxis,
            },
            yAxis: {
                type: 'value',
                name: '单位:万吨',
                nameTextStyle:{
                    fontSize: 10,
                    color:'#6474b4'
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    show:false,
                    lineStyle: {
                        color: '#6995aa'
                    },
                    onZero: false
                },
                axisLabel: {
                    fontSize: 10,
                    color: '#6474b4'
                },
                splitLine: {
                    lineStyle: {
                        type: 'dotted',
                        color: '#28379c'
                    }
                },
                splitNumber:4,
                scale: true
            },
            series: series
        };
        return lineoption;
    };
    var line_C = echarts.init(document.getElementById("lineChart"));

    line_C.setOption(lineChart(lineChartData));

    window.addEventListener("resize", function () {
        line_C.resize();
    });
    
}

init_lineChart(lineChartData);//调用位置